#include "Timer.h"

#include <utility>
#include "Util.h"
namespace xncc {
namespace foundation {
    Timer::Timer(types::Task tsk, int64_t when, int64_t interval)
        : t_(std::move(tsk)),
          expiration_(when),
          interval_(interval),
          isPeriod_(interval > 0),
          seqNo_(shared::CommonBusi::generateSeqNo())
    {
    }

    void Timer::restart(int64_t now)
    {
        if (isPeriod_) {
            expiration_ = now + interval_;
        }
        else {
            expiration_ = 0;
        }
    }
}  // namespace foundation
}  // namespace xncc